<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
	<title>Symbol 不能使用 for/in、for/of 遍历操作</title>
	<style type="text/css">
	* {
		padding: 0;
		margin: 0;
	}
    </style>
</head>
<body>
	<div class="container">
		<h1>getOwnPropertySymbols</h1>
	</div>
	<script src="https://cdn.staticfile.org/jquery/3.2.0/jquery.js"></script>
	<script type="text/javascript">
	function type(data) {
		return Object.prototype.toString.call(data)
	}

	// getOwnPropertySymbols
	let symbol = Symbol('后盾人')
	let obj = {
		name: 'houdun.com',
		[symbol] : "houdunren",
	}

	var ret = Object.getOwnPropertySymbols(obj);
	console.log(ret, typeof ret, type(ret))
	console.log(typeof symbol, type( [symbol]))
	console.log('-----------------------\n')
	
	// 可以使用 Object.getOwnPropertySymbols 获取所有Symbol属性
	for (const key of Object.getOwnPropertySymbols(obj)) {
	  console.log(key, typeof key);
	}

	console.log('-----------------------\n')
	
	// 也可以使用 Reflect.ownKeys(obj) 获取所有属性包括Symbol
	for(const key of Reflect.ownKeys(obj)) {
		console.log(key, typeof key, type(key))
	}


	
	</script>
</body>
</html>